import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/pages/student/myFavoriteBooks.dart';
import 'package:ichinesereader/routes/routePages.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/buttons/floatingActionButtonsParentSwitchChild.dart';
import 'package:ichinesereader/widgets/layouts/appdrawerParent.dart';
import 'package:ichinesereader/widgets/layouts/customAppBar.dart';
import 'package:ichinesereader/widgets/sidebars/parentSidebar.dart';
import '../../themes/pageStyles.dart';

class MyFavoritesPageForChild extends StatelessWidget {
  static const String routeName = '/parent/myfavorites';

  @override
  Widget build(BuildContext context) {
    Log.debug('build parent child\'s favoirte');
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;
    final isBigScreen =
        MediaQuery.of(context).size.width > Constants.DefinedScreenBigSize;
    int _selectedSidebarItem = RoutePages.parentPageItems
        .indexWhere((page) => page.route == Get.currentRoute);
    final PageStyles _pageStyles = PageStyles();

    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: isSmallScreen
              ? CustomAppBar(title: "Child's Favorites".tr)
              : null,
          drawer: isSmallScreen ? ParentAppDrawer() : null,
          floatingActionButton: FloatingActionButtonsParentSwitchChild(),
          body: Container(
            decoration: _pageStyles.pageBoxDecoration(),
            child: Row(
              children: [
                Visibility(
                  visible: !isSmallScreen,
                  child: ParentSidebarX(
                      selectedIndex: _selectedSidebarItem,
                      isBigScreen: isBigScreen),
                ),
                Expanded(
                  child: Container(
                    margin: _pageStyles.mainContainerPageEdgeInsets(),
                    child: Column(
                      children: [Expanded(child: MyFavoriteBooksForStudent())],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}
